


let globalCache = {

    _lstV2:[],
    _lstV3:[],
    _lstMat4:[],
    _lstRect:[],
    _lstColor:[],

    get_v2(){
        if(this._lstV2.length < 1){
            return cc.v2();
        }
        return this._lstV2.pop();
    },

    put_v2(v2){
        if(this._lstV2.length < 10){
            v2.x = v2.y = 0;
            this._lstV2.push(v2);
        }
    },

    get_v3(){
        if(this._lstV3.length < 1){
            return cc.v3();
        }
        return this._lstV3.pop();
    },

    put_v3(v3){
        if(this._lstV3.length < 10){
            v3.x = v3.y = v3.z = 0;
            this._lstV3.push(v3);
        }
    },

    get_mat4(){
        if(this._lstMat4.length < 1){
            return cc.mat4();
        }
        return this._lstMat4.pop();
    },

    put_mat4(m4){
        if(this._lstMat4.length < 10){
            cc.Mat4.identity(m4);
            this._lstMat4.push(m4);
        }
    },

    get_rect(){
        if(this._lstRect.length < 1){
            return cc.rect();
        }
        return this._lstRect.pop();
    },

    put_rect(rect){
        if(this._lstRect.length < 10){
            rect.x = rect.y = rect.width = rect.height = 0;
            this._lstRect.push(rect);
        }
    },

    get_color(){
        if(this._lstColor.length < 1){
            return cc.color();
        }
        return this._lstColor.pop();
    },

    put_color(color){
        if(this._lstColor.length < 10){
            color.r = color.g = color.b = 0;
            color.a = 255;
            this._lstColor.push(color);
        }
    }
};

export {
    globalCache
}
